<template>
  <div>
    <ul>
      <li>
        <router-link to="/about/indexTwo" active-class="active"
          >干饭真好</router-link
        >
      </li>
      <li>
        <router-link to="/about/aboutTwo" active-class="active"
          >干饭真香</router-link
        >
      </li>
      <li>
        <router-link to="/about/userTwo" active-class="active"
          >干饭真棒</router-link
        >
      </li>
    </ul>
    <div><button @click="add">随机显示</button></div>
    <div>
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
export default {
  methods: {
    add() {
      let a = Math.floor(Math.random() * 3);
      switch (a) {
        case 0:
          this.$router.push({
            path: "/about/indexTwo",
          });
          break;
        case 1:
          this.$router.push({
            path: "/about/aboutTwo",
          });
          break;
        case 2:
          this.$router.push({
            path: "/about/userTwo",
          });
          break;
      }
      //;
    },
  },
};
</script>

<style>
.active {
  color: red;
}
</style>